package com.patrol.patrol.ui.route;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.patrol.patrol.R;
import com.patrol.patrol.ui.BaseActivity;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class RoutesActivity extends BaseActivity {

    RecyclerView recyclerView;
    RouteAdapter routeAdapter;
    List<Route> routes;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_route);
        findViewById(R.id.img_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        recyclerView = findViewById(R.id.rcy_route);
        recyclerView.setLayoutManager(new LinearLayoutManager(this,LinearLayoutManager.VERTICAL,false));

        routes = new ArrayList<>();
        routeAdapter = new RouteAdapter(this,routes);
        recyclerView.setAdapter(routeAdapter);

        String[] a = new String[]{"AAA","BBB","CCC"};
        List<String> aa = new ArrayList<>(Arrays.asList(a));
        String[] b = new String[]{"DDD","EEE","FFF","GGG"};
        List<String> bb = new ArrayList<>(Arrays.asList(b));
        String[] c = new String[]{"HHH","III","JJJ","KKK","LLL"};
        List<String> cc = new ArrayList<>(Arrays.asList(c));
        routes.add(new Route().setFirstTitle("部门A").setSubTitles(aa));
        routes.add(new Route().setFirstTitle("部门B").setSubTitles(bb));
        routes.add(new Route().setFirstTitle("部门C").setSubTitles(cc));

        routeAdapter.notifyDataChange();

    }
}
